/* ***********************************************************************
  FILE:              fibon.c
  VERSION:           1.0
  DATE:              Jan 2009
  AUTHOR:            F. de Sande
  COMMENTS TO:       fsande@ull.es
  DESCRIPTION:       
  COMMENTS:	     
  REFERENCES:        
  INPUT:             
  OUTPUT:            
  FILE FORMATS:      -
  RESTRICTIONS:      -
  REVISION HISTORY:
**************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <omp.h>

/* First fibonnaci number to compute */
#ifndef N
#define N 40    
#endif

/* Number of fibonacci numbers to compute */
#ifndef NFIB 
#define NFIB 1  
#endif

/* Computes (recursively) fibonnaci number n */
unsigned fib(unsigned n) {
   int x, y;
   if (n < 2) {
      return (n);
   } else {
      x = fib(n - 1);
      y = fib(n - 2);
    return (x + y);
   }
}

int main(int argc, char *argv[]) {
  double start, end;
  int i;
    
  printf("Starting at fib(%d)\n", N);
  start = omp_get_wtime();
  {
    for (i = 0; i < NFIB; i++) {
      printf("fib(%i): %d\n", i + N, fib(i + N));
    }
  }
  end = omp_get_wtime();

  printf("Compute Time: %f seconds\n", end - start);
  return 0;
}

/*
 * vim:ts=2:sw=2
 */
